<template>
  <div>
    <div>
      <button @click="toLogin">登录</button>
    </div>
  </div>
</template>


<script>
import Vue from 'vue';
import { Notify } from 'vant';
// 全局注册
Vue.use(Notify);

export default {
  methods: {
    toLogin() {
      if (localStorage.getItem('token')) {
        Notify({ type: 'primary', message: '用户已登录无需重复登录' });
      } else {
        this.$router.push('/login')
      }
    }
  }
}
</script>